Test Series - java script

Test Number 22/92

Q: Which is a fast C++ based JavaScript interpreter?
A. Node
B. Sockets
C. Processors
D. Closures
Solution: Node.js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser. Node is a fast C++-based JavaScript interpreter with bindings to the low-level Unix APIs for working with processes, files, network sockets, etc., and also to HTTP client and server APIs.
Q: Why does the Node rely on event handlers?
A. APIs are synchronous
B. APIs are asynchronous
C. APIs are reusable
D. APIs are modular
Solution: For handling the spontaneous events occurring on the web page the event handlers are important. Because the APIs are asynchronous, Node relies on event handlers, which are often implemented using nested functions and closures.
Q: What is the command to run the node programs?
A. node(program.js)
B. program.js
C. node program.js
D. node.program.js
Solution: The node programs can be run with the command:node program.js. The command can be written more simply like node program.
Q: What is the alternative command used in Node for load()?
A. store()
B. module()
C. log()
D. require()
Solution: require() is used for including other javascript files. Use require() instead of load(). It loads and executes (only once) the named module, returning an object that contains its exported symbols.
Q: What is the command used for debugging output in Node?
A. print();
B. console.log(…);
C. debug(…);
D. execute(…);
Solution: Console.log() prints the content in the argument on to the output screen. Node defines console.log() for debugging output like browsers do.
Q: What is the code to print hello one second from now?
A. setTimeout(function() { console.log(“Hello World”); }, 1000);
B. setTimeout(function() { 1000, console.log(“Hello World”); });
C. setTimeout(function(1000) { console.log(“Hello World”); });
D. setTimeout(function() { console.log(“Hello World”); });
Solution: SetTimeout function is used to hold the execution of the code with the required amount of time. The argument of the setTimeout includes the function which is to be executed followed by the time after which the code is to be executed.
Q: Among the below given functions, Node supports which of the following client-side timer functions?
A. getInterval()
B. Interval()
C. clearTime()
D. clearTimeout()
Solution: Client-side timer functions are used to perform applications based on time constraints. Node supports the client-side timer functions set setTimeout(), setInterval(), clearTimeout(), and clearInterval().
Q: The necessary globals of a node are defined under which namespace?
A. variables
B. system
C. process
D. using
Solution: The process object is a global that provides information about, and control over, the current Node.js process. Node defines other important globals under the process namespace.
Q: Why does Node not block while waiting for operations to complete?
A. Static
B. Asynchronous
C. Synchronous
D. Recursive
Solution: Node executes the function the in one go without any waiting or blocking. Because the Node’s functions and methods are asynchronous, they do not block while waiting for operations to complete.
Q:  Which is the method used for registering handlers?
A. on()
B. register()
C. add()
D. include()
Solution: The on() method attaches one or more event handlers for the selected elements and child elements. Node objects that generate events (known as event emitters) define an on() method for registering handlers.

You Have Score    /10